home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / mus2v131.zip / delsng.cmd next >
OS/2 REXX Batch file  |  1996-03-03  |  4KB  |  136 lines

  1. /* ########################################################################
  2.  
  3.    This REXX script will communicate with a running Module Player that
  4.    support a Command Pipe.
  5.  
  6.    The Following commands are used
  7.       Query Song  -- Returns three lines, first is the file name, second is the
  8.                      index and third is the song title. They represent
  9.                      the currently playing song.
  10.       SongList EraseIndx -- Nukes 1 item in the list (by index)
  11.       Play Next -- Plays the next song
  12.  
  13.    ########################################################################
  14. */
  15. '@echo off'                       /* Don't echo commands */
  16. say " Module Player Delete Current Song From SongList V1.0                     Ethos"
  17.    call OpenPlayer
  18.    if Result <> 0 then do
  19.       say "Error" Error
  20.       return
  21.    end
  22.  
  23.    /* Load RexxUtil functions */
  24.    if RxFuncQuery("SysLoadFuncs") then do
  25.       /* RexxUtil functions have not been loaded. */
  26.       rc = RxFuncAdd("SysLoadFuncs","RexxUtil","SysLoadFuncs")
  27.       if \(rc = 0) then do
  28.          say "RexxUtil could not be loaded!"
  29.          exit
  30.       end
  31.  
  32.       call SysLoadFuncs
  33.    end
  34.  
  35.    if CallPlayer("Query","Song","") <> 0 then do
  36.       say "Error" Error
  37.       return
  38.    end
  39.    Say "Currently Playing Song" Result.1 "'" || Result.3 || "'"
  40.    Say "Deleteing ->" Result.1
  41.    call SysSleep 3
  42.    'del' Result.1
  43.    say "Done"
  44.  
  45.    if CallPlayer("SongList","EraseIndx",Result.2) <> 0 then do
  46.       say "Error" Error
  47.       return
  48.    end
  49.  
  50.    say "Erased from the Song List"
  51.  
  52.    if CallPlayer("Play","Next","") <> 0 then do
  53.       say "Error" Error
  54.       return
  55.    end
  56.    say "Playing Next Song"
  57. return
  58.  
  59. /* ########################################################################
  60.  
  61.    Function - CallPlayer
  62.    Eg - if (CallPlayer("Query","Song","") <> 0) then Error
  63.  
  64.    Description - This procedure sends a command message to the player.
  65.                  An error is returned if the player doesn't understand
  66.                  the message or something else is wrong.
  67.                    Result - A stem containing each line of the result
  68.                    Error - Global error code
  69.  
  70.    ########################################################################
  71. */
  72. CallPlayer: procedure expose Result. Player Error
  73.    parse arg Command, SCommand, Arg
  74.  
  75.    Error = ""
  76.    Result.0 = 0
  77.  
  78.    /* Player not loaded */
  79.    if (Player = "") then do
  80.       Error = "Player not Inited"
  81.       return 1
  82.    end
  83.  
  84.    call lineout Player,Command SCommand Arg
  85.  
  86.    /* Get all the results */
  87.    do while (1)
  88.       Line = linein(Player)
  89.  
  90.       /* Error or something */
  91.       if (pos("!!",Line) = 1) then do
  92.          if (Line = "!! OK") then
  93.             return 0
  94.          Error = substr(Line,4)
  95.          return 1
  96.       end;
  97.  
  98.       Result.0 = Result.0 + 1
  99.       I = Result.0
  100.       Result.I = Line
  101.    end
  102.  
  103. return 0
  104.  
  105. /* ########################################################################
  106.  
  107.    Function - OpenPlayer
  108.    Eg - call OpenPlayer
  109.  
  110.    Description - This procedure opens the pipe and sets the following:
  111.                    Player - The name of the pipe - \pipe\Player
  112.                    Version - The pipe comminication version
  113.                    Type - The program running on the other end, 'Text UI'
  114.                    Error - Global Error Code
  115.  
  116.    ########################################################################
  117. */
  118. OpenPlayer:procedure expose Player Version Type Error
  119.    Error = ""
  120.  
  121.    Result = Stream("\pipe\ModulePlayer","C","OPEN");
  122.    if (Result <> "READY:") then do
  123.       Error = "Unable to communicate with the  Player, is it running?"
  124.       Player = ""
  125.       return 1
  126.    end
  127.    Player = "\pipe\ModulePlayer"
  128.  
  129.    /* Get the version */
  130.    S = linein(Player)
  131.    parse var S 'V' Version .
  132.    Type = linein(Player)
  133. return 0
  134.  
  135.  
  136.